#include<iostream>
#include<vector>
using namespace std;
const int maxn=32;
bool flag=false;
vector<int> ans;
int N,pre[maxn],post[maxn];
struct node{
    int data;
    node* lchild=NULL;
    node* rchild=NULL;
}Node[maxn];

node* create(int preL,int preR,int postL,int postR){
    if(preR-preL+1==2 && postR-postL+1==2){
        if(pre[preL]==post[postR] && pre[preR]==post[postL]){
            flag=true;
        }
    }
    if(preL>preR || postL>postR) return NULL;
    node* root=new node;
    root->data=pre[preL];
    if(preL==preR || postL==postR) return root;
    int lchild;
    if(preR-preL>0) {lchild=pre[preL+1];}
    else {lchild=pre[preL];}
    int index;
    for(int i=postL;i<=postR;i++){
        if(post[i]==lchild) {index=i;break;}
    }
    int k=index-postL;
    root->lchild=create(preL+1,preL+1+k,postL,index);
    root->rchild=create(preL+1+k+1,preR,index+1,postR-1);
    return root;
}

void inorder(node* root){
    if(root==NULL) return;
    inorder(root->lchild);
    ans.push_back(root->data);
    inorder(root->rchild);
}
int main(){
    //freopen("in.txt","r",stdin);
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        scanf("%d",&pre[i]);
    }
    for(int i=1;i<=N;i++){
        scanf("%d",&post[i]);
    }
    node* root=new node;
    root=create(1,N,1,N);
    inorder(root);
    if(flag){printf("No\n");}
    else {printf("Yes\n");}
    for(int i=0;i<ans.size();i++){
        if(i==0) {printf("%d",ans[i]);}
        else {printf(" %d",ans[i]);}
    }
    printf("\n");
}
